// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ccr
{
	public sealed class CcrFollowRequestParameters : RequestParameters<CcrFollowRequestParameters>
	{
		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.WaitForActiveShards? WaitForActiveShards { get => Q<Elastic.Clients.Elasticsearch.WaitForActiveShards?>("wait_for_active_shards"); set => Q("wait_for_active_shards", value); }
	}

	public sealed partial class CcrFollowRequest : PlainRequestBase<CcrFollowRequestParameters>
	{
		public CcrFollowRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r.Required("index", index))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.CrossClusterReplicationFollow;
		protected override HttpMethod HttpMethod => HttpMethod.PUT;
		protected override bool SupportsBody => true;
		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.WaitForActiveShards? WaitForActiveShards { get => Q<Elastic.Clients.Elasticsearch.WaitForActiveShards?>("wait_for_active_shards"); set => Q("wait_for_active_shards", value); }

		[JsonInclude]
		[JsonPropertyName("leader_index")]
		public Elastic.Clients.Elasticsearch.IndexName? LeaderIndex { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_outstanding_read_requests")]
		public long? MaxOutstandingReadRequests { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_outstanding_write_requests")]
		public long? MaxOutstandingWriteRequests { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_read_request_operation_count")]
		public long? MaxReadRequestOperationCount { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_read_request_size")]
		public string? MaxReadRequestSize { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_retry_delay")]
		public Elastic.Clients.Elasticsearch.Duration? MaxRetryDelay { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_write_buffer_count")]
		public long? MaxWriteBufferCount { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_write_buffer_size")]
		public string? MaxWriteBufferSize { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_write_request_operation_count")]
		public long? MaxWriteRequestOperationCount { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_write_request_size")]
		public string? MaxWriteRequestSize { get; set; }

		[JsonInclude]
		[JsonPropertyName("read_poll_timeout")]
		public Elastic.Clients.Elasticsearch.Duration? ReadPollTimeout { get; set; }

		[JsonInclude]
		[JsonPropertyName("remote_cluster")]
		public string? RemoteCluster { get; set; }
	}

	public sealed partial class CcrFollowRequestDescriptor<TDocument> : RequestDescriptorBase<CcrFollowRequestDescriptor<TDocument>, CcrFollowRequestParameters>
	{
		internal CcrFollowRequestDescriptor(Action<CcrFollowRequestDescriptor<TDocument>> configure) => configure.Invoke(this);
		public CcrFollowRequestDescriptor(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r.Required("index", index))
		{
		}

		public CcrFollowRequestDescriptor(TDocument document) : this(typeof(TDocument))
		{
		}

		internal CcrFollowRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.CrossClusterReplicationFollow;
		protected override HttpMethod HttpMethod => HttpMethod.PUT;
		protected override bool SupportsBody => true;
		public CcrFollowRequestDescriptor<TDocument> WaitForActiveShards(Elastic.Clients.Elasticsearch.WaitForActiveShards? waitForActiveShards) => Qs("wait_for_active_shards", waitForActiveShards);
		public CcrFollowRequestDescriptor<TDocument> Index(Elastic.Clients.Elasticsearch.IndexName index)
		{
			RouteValues.Required("index", index);
			return Self;
		}

		private Elastic.Clients.Elasticsearch.IndexName? LeaderIndexValue { get; set; }

		private long? MaxOutstandingReadRequestsValue { get; set; }

		private long? MaxOutstandingWriteRequestsValue { get; set; }

		private long? MaxReadRequestOperationCountValue { get; set; }

		private string? MaxReadRequestSizeValue { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? MaxRetryDelayValue { get; set; }

		private long? MaxWriteBufferCountValue { get; set; }

		private string? MaxWriteBufferSizeValue { get; set; }

		private long? MaxWriteRequestOperationCountValue { get; set; }

		private string? MaxWriteRequestSizeValue { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? ReadPollTimeoutValue { get; set; }

		private string? RemoteClusterValue { get; set; }

		public CcrFollowRequestDescriptor<TDocument> LeaderIndex(Elastic.Clients.Elasticsearch.IndexName? leaderIndex)
		{
			LeaderIndexValue = leaderIndex;
			return Self;
		}

		public CcrFollowRequestDescriptor<TDocument> MaxOutstandingReadRequests(long? maxOutstandingReadRequests)
		{
			MaxOutstandingReadRequestsValue = maxOutstandingReadRequests;
			return Self;
		}

		public CcrFollowRequestDescriptor<TDocument> MaxOutstandingWriteRequests(long? maxOutstandingWriteRequests)
		{
			MaxOutstandingWriteRequestsValue = maxOutstandingWriteRequests;
			return Self;
		}

		public CcrFollowRequestDescriptor<TDocument> MaxReadRequestOperationCount(long? maxReadRequestOperationCount)
		{
			MaxReadRequestOperationCountValue = maxReadRequestOperationCount;
			return Self;
		}

		public CcrFollowRequestDescriptor<TDocument> MaxReadRequestSize(string? maxReadRequestSize)
		{
			MaxReadRequestSizeValue = maxReadRequestSize;
			return Self;
		}

		public CcrFollowRequestDescriptor<TDocument> MaxRetryDelay(Elastic.Clients.Elasticsearch.Duration? maxRetryDelay)
		{
			MaxRetryDelayValue = maxRetryDelay;
			return Self;
		}

		public CcrFollowRequestDescriptor<TDocument> MaxWriteBufferCount(long? maxWriteBufferCount)
		{
			MaxWriteBufferCountValue = maxWriteBufferCount;
			return Self;
		}

		public CcrFollowRequestDescriptor<TDocument> MaxWriteBufferSize(string? maxWriteBufferSize)
		{
			MaxWriteBufferSizeValue = maxWriteBufferSize;
			return Self;
		}

		public CcrFollowRequestDescriptor<TDocument> MaxWriteRequestOperationCount(long? maxWriteRequestOperationCount)
		{
			MaxWriteRequestOperationCountValue = maxWriteRequestOperationCount;
			return Self;
		}

		public CcrFollowRequestDescriptor<TDocument> MaxWriteRequestSize(string? maxWriteRequestSize)
		{
			MaxWriteRequestSizeValue = maxWriteRequestSize;
			return Self;
		}

		public CcrFollowRequestDescriptor<TDocument> ReadPollTimeout(Elastic.Clients.Elasticsearch.Duration? readPollTimeout)
		{
			ReadPollTimeoutValue = readPollTimeout;
			return Self;
		}

		public CcrFollowRequestDescriptor<TDocument> RemoteCluster(string? remoteCluster)
		{
			RemoteClusterValue = remoteCluster;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (LeaderIndexValue is not null)
			{
				writer.WritePropertyName("leader_index");
				JsonSerializer.Serialize(writer, LeaderIndexValue, options);
			}

			if (MaxOutstandingReadRequestsValue.HasValue)
			{
				writer.WritePropertyName("max_outstanding_read_requests");
				writer.WriteNumberValue(MaxOutstandingReadRequestsValue.Value);
			}

			if (MaxOutstandingWriteRequestsValue.HasValue)
			{
				writer.WritePropertyName("max_outstanding_write_requests");
				writer.WriteNumberValue(MaxOutstandingWriteRequestsValue.Value);
			}

			if (MaxReadRequestOperationCountValue.HasValue)
			{
				writer.WritePropertyName("max_read_request_operation_count");
				writer.WriteNumberValue(MaxReadRequestOperationCountValue.Value);
			}

			if (!string.IsNullOrEmpty(MaxReadRequestSizeValue))
			{
				writer.WritePropertyName("max_read_request_size");
				writer.WriteStringValue(MaxReadRequestSizeValue);
			}

			if (MaxRetryDelayValue is not null)
			{
				writer.WritePropertyName("max_retry_delay");
				JsonSerializer.Serialize(writer, MaxRetryDelayValue, options);
			}

			if (MaxWriteBufferCountValue.HasValue)
			{
				writer.WritePropertyName("max_write_buffer_count");
				writer.WriteNumberValue(MaxWriteBufferCountValue.Value);
			}

			if (!string.IsNullOrEmpty(MaxWriteBufferSizeValue))
			{
				writer.WritePropertyName("max_write_buffer_size");
				writer.WriteStringValue(MaxWriteBufferSizeValue);
			}

			if (MaxWriteRequestOperationCountValue.HasValue)
			{
				writer.WritePropertyName("max_write_request_operation_count");
				writer.WriteNumberValue(MaxWriteRequestOperationCountValue.Value);
			}

			if (!string.IsNullOrEmpty(MaxWriteRequestSizeValue))
			{
				writer.WritePropertyName("max_write_request_size");
				writer.WriteStringValue(MaxWriteRequestSizeValue);
			}

			if (ReadPollTimeoutValue is not null)
			{
				writer.WritePropertyName("read_poll_timeout");
				JsonSerializer.Serialize(writer, ReadPollTimeoutValue, options);
			}

			if (!string.IsNullOrEmpty(RemoteClusterValue))
			{
				writer.WritePropertyName("remote_cluster");
				writer.WriteStringValue(RemoteClusterValue);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class CcrFollowRequestDescriptor : RequestDescriptorBase<CcrFollowRequestDescriptor, CcrFollowRequestParameters>
	{
		internal CcrFollowRequestDescriptor(Action<CcrFollowRequestDescriptor> configure) => configure.Invoke(this);
		public CcrFollowRequestDescriptor(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r.Required("index", index))
		{
		}

		internal CcrFollowRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.CrossClusterReplicationFollow;
		protected override HttpMethod HttpMethod => HttpMethod.PUT;
		protected override bool SupportsBody => true;
		public CcrFollowRequestDescriptor WaitForActiveShards(Elastic.Clients.Elasticsearch.WaitForActiveShards? waitForActiveShards) => Qs("wait_for_active_shards", waitForActiveShards);
		public CcrFollowRequestDescriptor Index(Elastic.Clients.Elasticsearch.IndexName index)
		{
			RouteValues.Required("index", index);
			return Self;
		}

		private Elastic.Clients.Elasticsearch.IndexName? LeaderIndexValue { get; set; }

		private long? MaxOutstandingReadRequestsValue { get; set; }

		private long? MaxOutstandingWriteRequestsValue { get; set; }

		private long? MaxReadRequestOperationCountValue { get; set; }

		private string? MaxReadRequestSizeValue { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? MaxRetryDelayValue { get; set; }

		private long? MaxWriteBufferCountValue { get; set; }

		private string? MaxWriteBufferSizeValue { get; set; }

		private long? MaxWriteRequestOperationCountValue { get; set; }

		private string? MaxWriteRequestSizeValue { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? ReadPollTimeoutValue { get; set; }

		private string? RemoteClusterValue { get; set; }

		public CcrFollowRequestDescriptor LeaderIndex(Elastic.Clients.Elasticsearch.IndexName? leaderIndex)
		{
			LeaderIndexValue = leaderIndex;
			return Self;
		}

		public CcrFollowRequestDescriptor MaxOutstandingReadRequests(long? maxOutstandingReadRequests)
		{
			MaxOutstandingReadRequestsValue = maxOutstandingReadRequests;
			return Self;
		}

		public CcrFollowRequestDescriptor MaxOutstandingWriteRequests(long? maxOutstandingWriteRequests)
		{
			MaxOutstandingWriteRequestsValue = maxOutstandingWriteRequests;
			return Self;
		}

		public CcrFollowRequestDescriptor MaxReadRequestOperationCount(long? maxReadRequestOperationCount)
		{
			MaxReadRequestOperationCountValue = maxReadRequestOperationCount;
			return Self;
		}

		public CcrFollowRequestDescriptor MaxReadRequestSize(string? maxReadRequestSize)
		{
			MaxReadRequestSizeValue = maxReadRequestSize;
			return Self;
		}

		public CcrFollowRequestDescriptor MaxRetryDelay(Elastic.Clients.Elasticsearch.Duration? maxRetryDelay)
		{
			MaxRetryDelayValue = maxRetryDelay;
			return Self;
		}

		public CcrFollowRequestDescriptor MaxWriteBufferCount(long? maxWriteBufferCount)
		{
			MaxWriteBufferCountValue = maxWriteBufferCount;
			return Self;
		}

		public CcrFollowRequestDescriptor MaxWriteBufferSize(string? maxWriteBufferSize)
		{
			MaxWriteBufferSizeValue = maxWriteBufferSize;
			return Self;
		}

		public CcrFollowRequestDescriptor MaxWriteRequestOperationCount(long? maxWriteRequestOperationCount)
		{
			MaxWriteRequestOperationCountValue = maxWriteRequestOperationCount;
			return Self;
		}

		public CcrFollowRequestDescriptor MaxWriteRequestSize(string? maxWriteRequestSize)
		{
			MaxWriteRequestSizeValue = maxWriteRequestSize;
			return Self;
		}

		public CcrFollowRequestDescriptor ReadPollTimeout(Elastic.Clients.Elasticsearch.Duration? readPollTimeout)
		{
			ReadPollTimeoutValue = readPollTimeout;
			return Self;
		}

		public CcrFollowRequestDescriptor RemoteCluster(string? remoteCluster)
		{
			RemoteClusterValue = remoteCluster;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (LeaderIndexValue is not null)
			{
				writer.WritePropertyName("leader_index");
				JsonSerializer.Serialize(writer, LeaderIndexValue, options);
			}

			if (MaxOutstandingReadRequestsValue.HasValue)
			{
				writer.WritePropertyName("max_outstanding_read_requests");
				writer.WriteNumberValue(MaxOutstandingReadRequestsValue.Value);
			}

			if (MaxOutstandingWriteRequestsValue.HasValue)
			{
				writer.WritePropertyName("max_outstanding_write_requests");
				writer.WriteNumberValue(MaxOutstandingWriteRequestsValue.Value);
			}

			if (MaxReadRequestOperationCountValue.HasValue)
			{
				writer.WritePropertyName("max_read_request_operation_count");
				writer.WriteNumberValue(MaxReadRequestOperationCountValue.Value);
			}

			if (!string.IsNullOrEmpty(MaxReadRequestSizeValue))
			{
				writer.WritePropertyName("max_read_request_size");
				writer.WriteStringValue(MaxReadRequestSizeValue);
			}

			if (MaxRetryDelayValue is not null)
			{
				writer.WritePropertyName("max_retry_delay");
				JsonSerializer.Serialize(writer, MaxRetryDelayValue, options);
			}

			if (MaxWriteBufferCountValue.HasValue)
			{
				writer.WritePropertyName("max_write_buffer_count");
				writer.WriteNumberValue(MaxWriteBufferCountValue.Value);
			}

			if (!string.IsNullOrEmpty(MaxWriteBufferSizeValue))
			{
				writer.WritePropertyName("max_write_buffer_size");
				writer.WriteStringValue(MaxWriteBufferSizeValue);
			}

			if (MaxWriteRequestOperationCountValue.HasValue)
			{
				writer.WritePropertyName("max_write_request_operation_count");
				writer.WriteNumberValue(MaxWriteRequestOperationCountValue.Value);
			}

			if (!string.IsNullOrEmpty(MaxWriteRequestSizeValue))
			{
				writer.WritePropertyName("max_write_request_size");
				writer.WriteStringValue(MaxWriteRequestSizeValue);
			}

			if (ReadPollTimeoutValue is not null)
			{
				writer.WritePropertyName("read_poll_timeout");
				JsonSerializer.Serialize(writer, ReadPollTimeoutValue, options);
			}

			if (!string.IsNullOrEmpty(RemoteClusterValue))
			{
				writer.WritePropertyName("remote_cluster");
				writer.WriteStringValue(RemoteClusterValue);
			}

			writer.WriteEndObject();
		}
	}
}